package com.jzd1997;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * @author jiangzd
 * @date 2019-08-14 09:58
 * @email 39627020@qq.com
 */
public class MyQueue {
    int[] elements = new int[0];
    public void push(int val){
        int[] newArr = new int[elements.length+1];
        for(int i=0;i<elements.length;i++){
            newArr[i] = elements[i];
        }
        newArr[elements.length] = val;
        elements = newArr;
    }

    public int pop(){
        int result = elements[0];
        int[] newArr = new int[elements.length-1];
        for(int i=0;i<newArr.length;i++){
            newArr[i] = elements[i+1];
        }
        elements = newArr;
        return result;
    }

    public static void main(String[] args){
        MyQueue queue = new MyQueue();
        queue.push(9);
        queue.push(8);
        queue.push(7);
        System.out.println(Arrays.toString(queue.elements));
        System.out.println(queue.pop());
        System.out.println(Arrays.toString(queue.elements));
        System.out.println(queue.pop());
        System.out.println(Arrays.toString(queue.elements));
        System.out.println(queue.pop());
        System.out.println(Arrays.toString(queue.elements));
    }
}